Ext.define('appmod.view.knowledge.category.Form', {
    extend: 'Ext.form.Panel',
    alias: [
		'widget.knowledge.category.form' ,
		'widget.knowledge-category-form'
	],
	region : 'center',
	bodyPadding: 10,
	requires: [
		'Ext.ux.TreePicker'
	],
	
	constructor: function (config) {
		
		if (config.fieldStores) {
			this.fieldStores = config.fieldStores;
		}
        this.callParent(arguments);
     },
	
    initComponent: function() {
        var me = this;

		var emptyStore = Ext.create('Ext.data.TreeStore',
		{
			root:
			{
				text: 'Root',
				id: 'root',
				expanded: true,
				children:
				[
				]
			},
			folderSort: false
		});
		
		var dsParentCatelog = emptyStore;
		
		if (me.fieldStores != null) {
			if (me.fieldStores['dsParentCategory']) {
				dsParentCatelog = me.fieldStores['dsParentCategory'];
			}
		}
		
        
        Ext.applyIf(me, {
            items: [
				{
					xtype: 'hiddenfield',
					name: 'id'
				},			
                {
                    xtype: 'treepicker',
					labelWidth: 60,
                    fieldLabel: '上级目录',
					store : dsParentCatelog,
					displayField:'text',
					//valueField:'id',
					name:'parentId',
					rootVisible:false,
				
                    anchor: '95%'
                },
                {
                    xtype: 'textfield',
					labelWidth: 60,
                    fieldLabel: '分类名称',
					name:'name',
                    anchor: '95%'
                },
            ]
        });
        
        me.callParent(arguments);
    }
});